<?
	include("../main_inc.php");
	include("../../functions.inc.php");
	include("../../classes/clsStats.php");
	
	
	
	$r= new ReturnRecord();  // base object for returning data or raw queries
	
	if($_POST['ViewType']) $ViewType=$_POST['ViewType'];
	else $ViewType="Day";
	
	if($_POST['Day']) $Day=$_POST['Day'];
	else $Day=date("d");
	
	if($_POST['Month']) $Month=$_POST['Month'];
	else $Month=date("m");
	
	if($_POST['Year']) $Year=$_POST['Year'];
	else $Year=date("Y");
	
	$stats = new Count_visitors($_SERVER['HTTP_HOST']);
	$stats->affiliateID=$_SESSION['AffKey'];
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Bubble Affiliate Program</title>

<link href="../../css/admin.css" rel="stylesheet" type="text/css">
<script src="../../jscript/menuArrayAffiliate.php" language="javascript"></script>
<script src="../../jscript/clock.js" language="javascript"></script>
<script language="JavaScript" src="<?=$rootdir?>jscript/calendar1.js"></script><!-- Date only with year scrolling -->
<script language="JavaScript" type="text/JavaScript">


function ShowHideDateFields(ViewType){
	if(ViewType=="Day"){
		Target=document.getElementById("Day");
		Target.style.display="";
		Target=document.getElementById("Month");
		Target.style.display="";
	}
	if(ViewType=="Month"){
		Target=document.getElementById("Day");
		Target.style.display="none";
		Target=document.getElementById("Month");
		Target.style.display="";
	}
	if(ViewType=="Year"){
		Target=document.getElementById("Day");
		Target.style.display="none";
		Target=document.getElementById("Month");
		Target.style.display="none";
	}
}
</script>
</head>

<body onLoad="funClock();">
<?php include("../header.php"); ?>
<table width="100%" border="0" cellspacing="25" cellpadding="0">
<tr>
<td valign="top" width="240"><div id="menu"><?php include("../menu.php"); ?></div></td>
<td valign="top" align="center"><div id="title">
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><form action="index.php"  method="post" name="form2" onSubmit="YY_checkform('form2','FirstName','#q','0','You must fill in the field Name.','Email','S','2','You must fill in a valid Email Address.','UserName','#q','0','You must fill in the field Username.','Password','#q','0','You must fill in the field Password','Password2','#Password','6','Passwords must match.');return document.MM_returnValue" >
          <div id="titleCompact">Impression Statistics</div><span class="RedText"><?php print $Message; ?></span><br>
        </form>
          <form id="form1" name="form1" method="post" action="">
            Results By:
            <select name="ViewType" id="ViewType" onChange="ShowHideDateFields(this.value)">
            <option value="Day" <?=($ViewType=="Day"? "selected" : "");?>>Day</option>
            <option value="Month" <?=($ViewType=="Month"? "selected" : "");?>>Month</option>
            <option value="Year" <?=($ViewType=="Year"? "selected" : "");?>>Year</option>
          </select>
            -&gt;
            <select name="Day" id="Day" <?=((($ViewType=="Month")or($ViewType=="Year")) ? "style='display:none'" : "");?>>
              <? 
					 	for($x=1;$x<32;$x++){
							$tmp=($x==$Day ? "selected" : "");
					 ?>
              <option value="<?=$x;?>" <?=$tmp?>>
                <?=$x;?>
                </option>
              <? };?>
            </select>
            <select name="Month" id="Month" <?=($ViewType=="Year" ? "style='display:none'" : "");?>>
              <? 
					 	for($x=1;$x<13;$x++){
							$tmp=($x==$Month ? "selected" : "");
					 ?>
              <option value="<?=$x;?>" <?=$tmp?>>
                <?=$x;?>
                </option>
              <? };?>
            </select>
            <select name="Year" id="Year">
              <? 
					 	for($x=2007;$x<=date("Y");$x++){
							$tmp=($x==$Year ? "selected" : "");
					 ?>
              <option value="<?=$x;?>" <?=$tmp?>>
                <?=$x;?>
                </option>
              <? };?>
            </select>
            <input type="submit" name="Submit" value="Show" />
            <br />
            <br />
            <table width="480" border="0" cellpadding="2" cellspacing="0" class="bordertable">
              <tr>
                <td width="20%">First visit at: </td>
                <td width="35%"><?php echo $stats->first_last_visit("first"); ?></td>
                <? 
							if($ViewType=="Month"){ 
								?>
                <td width="20%">Monthly Visits: </td>
                <td><?php echo $stats->show_visits_month($Month,$Year); ?></td>
                <?
							}elseif($ViewType=="Year"){
								?>
                <td width="20%">Yearly Visits: </td>
                <td><?php echo $stats->show_visits_year($Year); ?></td>
                <?
							}elseif($ViewType=="Day"){
								?>
                <td width="20%">Daily Visits: </td>
                <td><?php echo $stats->show_visits_today($Day,$Month,$Year); ?></td>
                <?
							}
						?>
              </tr>
              <tr>
                <td>Last visit at: </td>
                <td><?php echo $stats->first_last_visit("last"); ?></td>
                <td>Total visits: </td>
                <td><?php echo $stats->show_all_visits(); ?></td>
              </tr>
            </table>
            <p><span class="box">
              <? 
					if($ViewType=="Month"){ 
						echo $stats->stats_country($Year,$Month);
						echo $stats->stats_monthly($Month, $Year); 
					}elseif($ViewType=="Year"){
						echo $stats->stats_country($Year);
						echo $stats->stats_yearly($Year);
					}elseif($ViewType=="Day"){
						echo $stats->stats_country($Year,$Month,$Day);
						echo $stats->stats_dayly($Day,$Month, $Year);
					}
				?>
            </span></p>
            <p>
              <?
		  	if($ViewType=="Month"){ 
				print $stats->stats_se_results($Month,$Year) ;
			}elseif($ViewType=="Year"){
				print $stats->stats_se_results($Year) ;
			}elseif($ViewType=="Day"){
				print $stats->stats_se_results($Day,$Month,$Year) ;
			}
          	
		  ?>
            </p>
          </form></td>
    </tr>
  </table>
  <a href="#"></a></div>
  <div id="results2"></div>
  <div id="content"></div>
  </td>
</tr>
</table>

</body>
</html>
